#include <iostream>
#include <stack>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <queue>
using namespace std;
typedef long long LL;
const int MAXN=1007;
struct node{
    node(int a, int b) {x=a; y=b; };
    node() {};
    int x, y;
};
int M[MAXN][MAXN];
bool vis[MAXN][MAXN];
int cSet[MAXN*MAXN];
int n,m;
//并查集的定义
int Search(int ask) {
    if (ask == cSet[ask]) return ask;
    int t = Search(cSet[ask]);
    cSet[ask] = t;
    return t;
}
int Union(node a, node b) {
    int h1=a.x*m+a.y;
    int h2=b.x*m+b.y;
    h1 = Search(h1);
    h2 = Search(h2);
    cSet[h2] = h1;
    if (h1 != h2) return 1;
    return 0;
}
//并查集结束
int dir_x[] = {0, 1, 0, -1};
int dir_y[] = {1, 0, -1, 0};
void BFS(node a) {
    queue<node> q;
    q.push(a);
    vis[a.x][a.y] = true;
    while (!q.empty()) {
        node pre=q.front(); q.pop();
        int x, y;
        for (int i=0; i<4; ++i) {
            x=pre.x+dir_x[i]; y=pre.y+dir_y[i];
            if (x<1 || x>=n) continue;
            if (y<1 || y>=m) continue;
            if (vis[x][y]) continue;
            if (M[x][y] != 0) continue;
            cSet[x*m+y] = cSet[a.x*m+a.y];
            q.push(node(x,y));
            vis[x][y] = true;
        }
    }
}
int res=0;
void Init() {
    memset(vis, 0, sizeof(vis));
    int len = n*m;
    for (int i=1; i<len; ++i) cSet[i] = i;
    for (int i=1; i<n; ++i) {
        for (int j=1; j<m; ++j) {
            if (M[i][j]==0 && !vis[i][j]) {
                BFS(node(i,j));
                ++res;
            }
        }
    }
}
struct line {
    int x1, y1, x2, y2;
    line(int a, int b, int c, int d) { x1=a; y1=b; x2=c; y2=d; };
    line(){};
};
void show() {
    for (int i=1; i<n; ++i) {
        for (int j=1; j<m; ++j) {
            cout<<M[i][j]<<" ";
        }
        cout<<endl;
    }
}
int main(int argc, char** argv) {
    #ifdef hai
    freopen("in.txt", "r", stdin);
    #endif
    memset(M, 0, sizeof(M));
    int k;
    cin>>n>>m>>k;
    ++n; ++m;
    int x1,y1,x2,y2;
    stack<int> ans;
    stack<line> ques;
    for (int i=0; i<k; ++i) {
        scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
        if (y1 > y2) swap(y1, y2);
        if (x1 > x2) swap(x1, x2);
        ques.push(line(x1,y1,x2,y2));
        if (x1==x2) {
            for (int i=y1; i<=y2; ++i) ++M[x1][i];
        }
        else {
            for (int i=x1; i<=x2; ++i) ++M[i][y1];
        }
    }
    Init();
    ans.push(res);
    //show();
    while (ques.size() != 1) {
        line l1 = ques.top(); ques.pop();
        x1=l1.x1; y1=l1.y1; x2=l1.x2; y2=l1.y2;
        if (x1==x2) {
            for (int i=y1; i<=y2; ++i) {
                --M[x1][i];
                node pre(x1, i);
                if (!M[x1][i]) {
                    ++res;
                    for (int j=0; j<4; ++j) {
                        int x=pre.x+dir_x[j];
                        int y=pre.y+dir_y[j];
                        if (x<1 || x>=n) continue;
                        if (y<1 || y>=m) continue;
                        if (M[x][y]) continue;
                        int status = Union(pre, node(x,y));
                        if (status) --res;
                    }
                }
            }
        }
        else {
            for (int i=x1; i<=x2; ++i) {
                --M[i][y1];
                node pre(i, y1);
                if (!M[i][y1]) {
                    ++res;
                    for (int j=0; j<4; ++j) {
                        int x=pre.x+dir_x[j];
                        int y=pre.y+dir_y[j];
                        if (x<1 || x>=n) continue;
                        if (y<1 || y>=m) continue;
                        if (M[x][y]) continue;
                        int status = Union(pre, node(x,y));
                        if (status) --res;
                    }
                }
            }
        }
        //cout<<"res: "<<res<<endl;
       // show();
        ans.push(res);
    }
    while (!ans.empty()) {
        int tt = ans.top(); ans.pop();
        cout<<tt<<endl;
    }
    return 0;
}
